package com.fjxd.city.web;

import com.fjxd.city.pojo.City;
import com.fjxd.city.service.CityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author csw
 */
@CrossOrigin
@RestController
@RequestMapping("/city")
public class CityController {
    @Autowired
    private CityService cityService;

    @GetMapping("/getCityAll")
    public List<City> getCityAll(){
        return cityService.getCityAll();
    }

    @GetMapping("/getCityById/{id}")
    public City getCityById(@PathVariable Integer id){
        return cityService.getCityById(id);
    }

    @GetMapping("/getCityIdByName/{cityName}")
    public Integer getCityIdByName(@PathVariable String cityName){
        return cityService.getCityIdByName(cityName);
    }

    @GetMapping("/getCityIdListByName/{upCity}/{downCity}")
    public List<City> getCityIdListByName(@PathVariable String upCity,@PathVariable String downCity){
        return cityService.getCityIdListByName(upCity,downCity);
    }
    @GetMapping("hello")
    public String hello(){
        System.out.println("qing");
        return "你好yayayaya";
  }
}
